#import "DDRegisterInput.h"
@interface DDRegisterInput()<JTWTextFieldDelegate>
@end
@implementation DDRegisterInput
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
- (DDTextField *)nameTF
{
    if (!_nameTF)
    {
        _nameTF = [[DDTextField alloc] init];
        _nameTF.type = JTWTextFieldTypeAccountList;
        _nameTF.returnKeyType = UIReturnKeyNext;
        _nameTF.customDelegate = self;
        [self addSubview:_nameTF];
        _nameTF.c_top.equal(self);
        _nameTF.c_left.equal(self);
        _nameTF.c_right.equal(self);
        _nameTF.c_height.equal(TEXTFILDHEIGHT);
    }
    return _nameTF;
}
- (DDTextField *)passTF
{
    if (!_passTF)
    {
        _passTF = [[DDTextField alloc] init];
        _passTF.type = JTWTextFieldTypePassword;
        _passTF.returnKeyType = UIReturnKeyNext;
        _passTF.customDelegate = self;
        [self addSubview:_passTF];
        _passTF.c_top.equal(self.nameTF.c_bottom);
        _passTF.c_left.equal(self);
        _passTF.c_right.equal(self);
        _passTF.c_height.equal(TEXTFILDHEIGHT);
    }
    return _passTF;
}
- (DDTextField *)confirmTF
{
    if (!_confirmTF)
    {
        _confirmTF = [[DDTextField alloc] init];
        _confirmTF.type = JTWTextFieldTypePassword;
        _confirmTF.customDelegate = self;
        [self addSubview:_confirmTF];
        _confirmTF.c_top.equal(self.passTF.c_bottom);
        _confirmTF.c_left.equal(self);
        _confirmTF.c_right.equal(self);
        _confirmTF.c_height.equal(TEXTFILDHEIGHT);
    }
    return _confirmTF;
}
- (void)setupline
{
    for (int i = 0; i < 2; i++)
    {
        UIView *line = [[UIView alloc] init];
        line.backgroundColor = CELL_LINE_COLOR;
        [self addSubview:line];
        line.c_left.equal(self).with.coffset(GAP);
        line.c_right.equal(self).with.coffset(-GAP);
        line.c_height.equal(1);
        if (i == 0)
            line.c_top.equal(self.passTF.c_top).with.coffset(-0.5);
        else
            line.c_bottom.equal(self.passTF.c_bottom).with.coffset(0.5);
    }
}
#pragma mark - YJDTextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField.returnKeyType == UIReturnKeyNext && [textField isEqual:self.nameTF])
    {
        [self.passTF becomeFirstResponder];
        return NO;
    }
    else if (textField.returnKeyType == UIReturnKeyNext && [textField isEqual:self.passTF])
    {
        [self.confirmTF becomeFirstResponder];
        return NO;
    }
    return YES;
}

@end
